using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Random = UnityEngine.Random;

public class GMCmd
{
    [MenuItem("GMCmd/删除数据")]
    public static void DeleteAllData()
    {
        PlayerPrefs.DeleteAll();
    }

    [MenuItem("GMCmd/读取表格")]
    public static void ReadTable()
    {
        PackageTable packageTable = Resources.Load<PackageTable>("TableData/PackageTable");
        foreach (var packageTableItem in packageTable.dataList)
        {
            Debug.Log(string.Format("id为{0},名称为{1}", packageTableItem.id, packageTableItem.name));
        }
    }

    [MenuItem("GMCmd/测试加载保存数据")]
    public static void LoadSaveTest()
    {
        PackageLocalData.Instance.tableItems = new List<PackageLocalItem>();
        for (int j = 0; j < 5; j++)
        {
            for (int i = 1; i < 9; i++)
            {
                int range = Random.Range(1, 9);
                PackageLocalItem packageLocalItem = new PackageLocalItem()
                {
                    uid = GUID.Generate().ToString(),
                    id = range,
                    isNew = i % 2 == 0 ? true : false,
                    level = i,
                    num = range
                };
                PackageLocalData.Instance.tableItems.Add(packageLocalItem);
            }
        }

        PackageLocalData.Instance.SaveData();

        List<PackageLocalItem> packageLocalItems = PackageLocalData.Instance.LoadData();
        foreach (PackageLocalItem localItem in packageLocalItems)
        {
            Debug.Log(localItem);
        }

        Debug.Log("保存的个数:" + packageLocalItems.Count);
    }

    [MenuItem("GMCmd/打开背包界面")]
    public static void OpenPackagePanel()
    {
        UIManager.Instance.OpenPanel(UIConst.PackagePanel);
    }


    [MenuItem("GMCmd/删除选中物品")]
    public static void RemoveData()
    {
    }
}